import os
import time
from httprunner.api import HttpRunner
from httprunner.report import gen_html_report


def run(path, env):
    # 创建 httprunner 对象
    runner = HttpRunner()
    run_report_path = r"report/" + time.strftime('%Y%m%d%H%M%S') + ".html"
    summary = runner.run(r'{}'.format(path), dot_env_path=env)
    gen_html_report(summary, report_file=run_report_path)
    print("report:", os.path.abspath('.') + '/' + run_report_path)


if __name__ == '__main__':
    # run(path='api/learning/添加选课.yml', env='conf/env/.env')
    # run(path='testcases/支付流程.yml', env='conf/env/.env')
    # run(path='testcases/learning/学习模块.yml', env='conf/env/.env')
    run(path='testcases/content/', env='conf/env/.env')
